home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
system
/
idrv01.zip
/
REMDRV.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-11-19
|
15KB
|
605 lines
PAGE 80,132
NAME remdrv
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; LUBLIN 24-02-1989 ;
; remdrv (v1.03) ;
; by JW ;
;...............................................................................;
ASSUME DS:code, SS:code ,CS:code ,ES:code
code SEGMENT Para Public 'code'
ORG 100h
start: jmp starter ; jump over data
;.................................................................................
lf equ 0ah ; line feed
cr equ 0dh ; carriage return
ZERO equ 0
TAB equ 9
DIB_SIZE equ 21h
FIRST_DIB equ 26h
FIRST_DA equ 3ch
NUM_OF_DRV equ 46h
TOTAL_NUM equ 47h
;...............................................................................
two db 2
dos_dep dw 0 ;0 - if dos 3.xx, 6 - if dos 4.xx or 5.xx
dos_dep2 db 0 ;0 - if dos 3.xx, 7 - if dos 4.xx or 5.xx
dos_dep3 dw 0 ;0 - if dos 3.xx, 1 - if dos 4.xx or 5.xx
flags db 0 ;1 - device was loaded by Idrv
drv_num db 0 ;current drive number
dos_seg dw 0 ;IMBDOS segment
drv_beg dw 0 ;Start of driver (must be on para boundry)
DIB_offs dw 0 ;Address of ...
DIB_seg dw 0 ; ... driver's DIB
header_offs dw 0
header_seg dw 0
last_offs dw 0 ;Address of ...
last_seg dw 0 ; ... DIB to be last
xms_offs dw 0
xms_seg dw 0
DA_flag db 0 ;non zero if proper Drive Area found
dev_flag db 0 ;set to 1 if block device
dev_count db 0
buf db 10 dup (0) ;area for device driver name
TXT_LEN equ $ - buf
first_dev db 0
db ': - '
last_dev db 0
db ': '
PATT_LEN equ $ - first_dev
one_dev db 0
db ':'
db 9 dup (' ')
ONLY_ONE equ $ - one_dev
signature db 'IdrvCB '
SIG_LEN equ $ - signature
;......................................................................................
;...............................................................................
starter: lea dx,header
call print_msg
mov ah,30h
int 21h ;Get DOS version number
lea dx,err_txt
cmp al,3
jb pr_txt
check_ver:
je get_list ;DOS v3.xx
cmp al,5 ;ver. above 5 ?
ja pr_txt ;yes,jump
mov dos_dep,6 ;No,change entry length of Open Files Table
mov dos_dep2,7 ;Change entry length of Drive Area
mov dos_dep3,1 ;Change entry length of Disk Info Block
get_list:
mov ah,52h
int 21h ;Get vector for int 25H
mov dos_seg,es
lea dx,not_PC_Dos
cmp word ptr es:52h,'UN' ;NUL device ?
jne pr_txt ;No,jump
les di,dword ptr es:02ah ;get address of DOS file table
add di,dos_dep ;change entry length of OFT if necessary
cmp byte ptr es:[di + 05bh],'C' ;Entry for dev. CON ?
jne pr_txt
cmp word ptr es:[di + 05ch],'NO'
je go_on
pr_txt:
jmp exit ;Jump to print message and qiut
go_on:
jmp ldrv
;...............................................................................
;...............................................................................
; messages to display
db 'Program written by Janusz Wojcik',cr,lf
err_txt db 'IDrv: That version of DOS is not supported!',cr,lf,lf,'$'
not_PC_Dos db 'IDrv: Not PC DOS ',cr,lf,lf,'$'
unlink_OK db cr,lf,'Device Driver uninstalled!',cr,lf,'$'
unlink_err db cr,lf,"Can't uninstall device driver!",cr,lf,'$'
unlink_quit db cr,lf,"Device driver not uninstalled!",cr,lf,'$'
header db 'Device Drivers Uninstaller v1.03',cr,lf
db '(C) 1990 by Janusz Wojcik Lublin,Poland.',cr,lf,lf,'$'
intro db 'This is device ','$'
not_idrv_dev db cr,lf,'Not loaded by Idrv !','$'
inquiry db cr,lf,'Delete it (y/n) ?','$'
;....................................................................................
;...............................................................................
device_header struc
next_offs dw ?
next_seg dw ?
dev_attr dw ?
dev_strategy dw ?
dev_interrupt dw ?
name_unit db 8 dup(?)
device_header ends
;...............................................................................
;...............................................................................
; the program body
;..............................................................................
ldrv:
mov es,dos_seg
mov si,48h
les si,dword ptr es:[si] ;Address of next dev. header
call copy_name ;get device driver name
call check_type ;check whether character or block device
call print_name ;display driver name
call check_icb ;check if Idrv Control Block precedes Device Header
lea dx,inquiry
call print_msg ;ask if remove device driver
mov ah,1
int 21h ;get char from stdin
cmp al,'y' ;remove dev. driver ?
je check_attr
lea dx,unlink_quit
jmp exit_OK
check_attr:
mov ax,es:dev_attr[si]
test ah,80h ;Character device ?
jnz unlnk_dev ;Yes,jump to unlink device headers
mov ax,es
mov dx,si
mov header_offs,dx
mov header_seg,ax
call seek_DIB ;Seek DIB pointing to ES:SI
jc exit_err
mov ax,DIB_offs
mov last_offs,ax
mov ax,DIB_seg
mov last_seg,ax
find_CDS:
mov si,es
mov dx,bx
mov DA_flag,ZERO
call seek_DA ;Seek DA poniting to ES:BX
cmp DA_flag,ZERO
jz exit_err
mov dx,header_offs
mov ax,header_seg
call seek_DIB
jnc find_CDS
chain_end:
les bx,dword ptr last_offs
mov si,dos_dep3
mov word ptr es:[si + bx + 18h],0ffffh ;Mark DIB as the last DIB
mov al,byte ptr es:[bx]
inc al
mov es,dos_seg
mov byte ptr es:NUM_OF_DRV,al ;Set real number of drives
unlnk_dev:
call unlink_dev ;Link device headers
lea dx,unlink_OK
jmp exit_OK
exit_err:
lea dx,unlink_err
exit_OK:
exit:
call print_msg
mov ah,4ch ;EXIT
mov al,1 ;Set return code
int 21h
;...............................................................................
print_msg:
mov ah,9
int 21h
ret
;..............................................................................
; copy_name:
; copy device driver name from Device Header into local buffer
; INPUT:
; ES:SI - address of Device Header for device
;..............................................................................
copy_name: push si
push es
push ds
mov ax,es:dev_attr[si]
test ah,80h ;Character device ?
jnz copy ;Yes,skip
mov dev_flag,1 ;Signal that block device
copy:
mov cx,4
mov di,offset buf
push es
pop ds ;DS = ES
add si,10
push cs
pop es ;ES = CS
cld
rep movsw ;copy device name
quit_copy:
pop ds
pop es
pop si
ret
;................................................................................
; check_type:
; check if block device.
; Prepare for displaying device name if so.
; INPUT:
; ES:SI - address of Device Header for device
;................................................................................
check_type:
cmp dev_flag,1
jne quit_check
push es
push si
mov ax,es
mov dx,si
call seek_DIBs
inc first_dev
add first_dev,40h
mov al,first_dev
mov last_dev,al
mov al,dev_count
dec al
add last_dev,al
pop si
pop es
quit_check:
ret
;...............................................................................
; seek_DIBS:
; find number of the first and the last device
; AX:DX - address of Device Header for device
;...............................................................................
seek_DIBs proc near
push es
push si
mov es,dos_seg
les bx,es:FIRST_DIB ;Get address of first DIB
mov si,dos_dep3
next_DIB_in_chain:
cmp word ptr es:[si + bx + 12h],dx
jnz if_last_DIB
cmp word ptr es:[si + bx + 14h],ax
jnz if_last_DIB
cmp dev_count,0 ;first matched device ?
jnz inc_count ;No,jump
mov cl,es:[bx] ;get device number
mov first_dev,cl
inc_count:
inc dev_count
if_last_DIB:
cmp word ptr es:[si + bx + 18h],0ffffh ;The last DIB ?
jz seek_DIBS_end ;Yes,jump
les bx,dword ptr es:[si + bx + 18h] ;Get addr. of next DIB
jmp next_DIB_in_chain
seek_DIBs_end:
pop si
pop es
clc
ret
seek_DIBs endp
;............................................................